package org.jeecg.modules.engine.service.impl;
public class DistanceCalculator {

    public static int[][] calculateDistances(int[][] array, int startRow, int startCol) {
        int rows = array.length;
        int cols = array[0].length;
        int[][] distances = new int[rows][cols];

        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < cols; j++) {
                int dx = i - startRow;
                int dy = j - startCol;
                distances[i][j] = (int) Math.sqrt(dx * dx + dy * dy);
            }
        }

        return distances;
    }

    public static void main(String[] args) {
        int[][] array = {
                {0, 0, 0, 0, 0,0,0,0,0,0,0,0,0,0,0,0},
                {0, 0, 0, 0, 0,0,0,0,0,0,0,0,0,0,0,0},
                {0, 0, 0, 0, 0,0,0,0,0,0,0,0,0,0,0,0},
                {0, 0, 0, 0, 0,0,0,0,0,0,0,0,0,0,0,0},
                {0, 0, 0, 0, 0,0,0,0,0,0,0,0,0,0,0,0},
                {0, 0, 0, 0, 0,0,0,0,0,0,0,0,0,0,0,0},
                {0, 0, 0, 0, 0,0,0,0,0,0,0,0,0,0,0,0},
                {0, 0, 0, 0, 0,0,0,0,0,0,0,0,0,0,0,0},
                {0, 0, 0, 0, 0,0,0,0,0,0,0,0,0,0,0,0},
                {0, 0, 0, 0, 0,0,0,0,0,0,0,0,0,0,0,0},
                {0, 0, 0, 0, 0,0,0,0,0,0,0,0,0,0,0,0},
                {0, 0, 0, 0, 0,0,0,0,0,0,0,0,0,0,0,0},
                {0, 0, 0, 0, 0,0,0,0,0,0,0,0,0,0,0,0},
                {0, 0, 0, 0, 0,0,0,0,0,0,0,0,0,0,0,0},
                {0, 0, 0, 0, 0,0,0,0,0,0,0,0,0,0,0,0},
                {0, 0, 0, 0, 0,0,0,0,0,0,0,0,0,0,0,0}
        };

        int[][] distances = calculateDistances(array, 7, 7);
        for (int i = 0; i < distances.length; i++) {
            for (int j = 0; j < distances[i].length; j++) {
                System.out.print(distances[i][j] + " ");
            }
            System.out.println();
        }
    }

}
